class_name JumpAbilitySpec
extends GameplayAbilitySpec


func _apply() -> void:
    var player := target.get_parent() as Player
    if not player:
        return

    var jump_height := target.attribute_set.get_attribute("jump_height").current_value
    var jump_time_to_peak := target.attribute_set.get_attribute("jump_time_to_peak").current_value
    var jump_speed := ((2.0 * jump_height) / jump_time_to_peak)
    player.velocity.y -= jump_speed

    player.add_tag(GameplayTagLibrary.Cooldown_Jump)


func _on_update(_delta: float) -> void:
    end_ability()


func _end_ability() -> void:
    pass
